//
//  MessageCenterSubCell.m
//  NewPro
//
//  Created by RYX on 2018/10/14.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "MessageCenterSubCell.h"
#import "MessageCenterModel.h"

@interface MessageCenterSubCell ()
{
    __weak IBOutlet UILabel *titleLa;
    __weak IBOutlet UILabel *desLa;
    __weak IBOutlet UILabel *timeLa;
    
    
    __weak IBOutlet UIImageView *newIm;
}
@end

@implementation MessageCenterSubCell

+ (instancetype)tempWithTableView:(UITableView *)tableView{
    
    
    MessageCenterSubCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELL"];
    
    if (!cell) {
        
        cell = [self Cell];
    }
    
    return cell;
}

+ (instancetype)Cell{
    
    ClassName
    return [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:0];
    
}

- (void)setModel:(MessageCenterModel *)model{
    
    titleLa.text = model.title;
    timeLa.text = [self changeWithTime:model.gmtCreate];
    desLa.text = model.content;
    
    newIm.alpha = 0;
    
    if ([model.isRead isEqualToString:@"0"]) {
        
        newIm.alpha = 1;
    }
}

- (NSString *)changeWithTime:(NSString *)timeStr{
    
    // iOS 生成的时间戳是10位
    NSTimeInterval interval  = [timeStr doubleValue] / 1000.0;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateString = [formatter stringFromDate: date];
    
    return dateString;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
